<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>StorageBufferNode - Three.js Docs</title>
	<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
	<script src="../scripts/highlight.min.js"></script>
	<link type="text/css" rel="stylesheet" href="../styles/highlight-three.css">
	<link type="text/css" rel="stylesheet" href="../styles/page.css">
</head>
<body>
		<p class="inheritance" translate="no"><a href="EventDispatcher.html">EventDispatcher</a> → <a href="Node.html">Node</a> → <a href="InputNode.html">InputNode</a> → <a href="UniformNode.html">UniformNode</a> → <a href="BufferNode.html">BufferNode</a> → </p>
	<h1 translate="no">StorageBufferNode</h1>
		<section>
			<header>
				<div class="class-description"><p>This node is used in context of compute shaders and allows to define a
storage buffer for data. A typical workflow is to create instances of
this node with the convenience functions <code>attributeArray()</code> or <code>instancedArray()</code>,
setup up a compute shader that writes into the buffers and then convert
the storage buffers to attribute nodes for rendering.</p></div>
				<h2>Code Example</h2>
				<div translate="no"><pre><code class="language-js">const positionBuffer = instancedArray( particleCount, 'vec3' ); // the storage buffer node
const computeInit = Fn( () => { // the compute shader
	const position = positionBuffer.element( instanceIndex );
	// compute position data
	position.x = 1;
	position.y = 1;
	position.z = 1;
} )().compute( particleCount );
const particleMaterial = new THREE.SpriteNodeMaterial();
particleMaterial.positionNode = positionBuffer.toAttribute();
renderer.computeAsync( computeInit );
</code></pre></div>
			</header>
			<article>
				<div class="container-overview">
					<h2>Constructor</h2>
					<h3 class="name name-method" id="StorageBufferNode" translate="no">new <a href="#StorageBufferNode">StorageBufferNode</a><span class="signature">( value : <span class="param-type"><a href="StorageBufferAttribute.html">StorageBufferAttribute</a> | <a href="StorageInstancedBufferAttribute.html">StorageInstancedBufferAttribute</a> | <a href="BufferAttribute.html">BufferAttribute</a></span>, bufferType : <span class="param-type">string | Struct</span>, bufferCount : <span class="param-type">number</span> )</span> </h3>
					<div class="method">
						<div class="description">
							<p>Constructs a new storage buffer node.</p>
						</div>
						<table class="params">
							<tbody>
								<tr>
									<td class="name">
										<strong>value</strong>
									</td>
									<td class="description last">
										<p>The buffer data.</p>
									</td>
								</tr>
								<tr>
									<td class="name">
										<strong>bufferType</strong>
									</td>
									<td class="description last">
										<p>The buffer type (e.g. <code>'vec3'</code>).</p>
										<p>Default is <code>null</code>.</p>
									</td>
								</tr>
								<tr>
									<td class="name">
										<strong>bufferCount</strong>
									</td>
									<td class="description last">
										<p>The buffer count.</p>
										<p>Default is <code>0</code>.</p>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
				</div>
				<h2 class="subsection-title">Properties</h2>
				<div class="member">
					<h3 class="name" id="access" translate="no">.<a href="#access">access</a><span class="type-signature"> : string</span> </h3>
					<div class="description">
						<p>The access type of the texture node.</p>
						<p>Default is <code>'readWrite'</code>.</p>
					</div>
				</div>
				<div class="member">
					<h3 class="name" id="global" translate="no">.<a href="#global">global</a><span class="type-signature"> : boolean</span> </h3>
					<div class="description">
						<p><code>StorageBufferNode</code> sets this property to <code>true</code> by default.</p>
						<p>Default is <code>true</code>.</p>
					</div>
						<dl class="details">
							<dt class="tag-overrides"><strong>Overrides:</strong> <a href="BufferNode.html#global">BufferNode#global</a></dt>
						</dl>
				</div>
				<div class="member">
					<h3 class="name" id="isAtomic" translate="no">.<a href="#isAtomic">isAtomic</a><span class="type-signature"> : boolean</span> </h3>
					<div class="description">
						<p>Whether the node is atomic or not.</p>
						<p>Default is <code>false</code>.</p>
					</div>
				</div>
				<div class="member">
					<h3 class="name" id="isPBO" translate="no">.<a href="#isPBO">isPBO</a><span class="type-signature"> : boolean</span> </h3>
					<div class="description">
						<p>Whether the node represents a PBO or not.
Only relevant for WebGL.</p>
						<p>Default is <code>false</code>.</p>
					</div>
				</div>
				<div class="member">
					<h3 class="name" id="isStorageBufferNode" translate="no">.<a href="#isStorageBufferNode">isStorageBufferNode</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
					<div class="description">
						<p>This flag can be used for type testing.</p>
						<p>Default is <code>true</code>.</p>
					</div>
				</div>
				<div class="member">
					<h3 class="name" id="structTypeNode" translate="no">.<a href="#structTypeNode">structTypeNode</a><span class="type-signature"> : <a href="StructTypeNode.html">StructTypeNode</a></span> </h3>
					<div class="description">
						<p>The buffer struct type.</p>
						<p>Default is <code>null</code>.</p>
					</div>
				</div>
				<h2 class="subsection-title">Methods</h2>
					<h3 class="name name-method" id="element" translate="no">.<a href="#element">element</a><span class="signature">( indexNode : <span class="param-type"><a href="IndexNode.html">IndexNode</a></span> )</span><span class="type-signature"> : <a href="StorageArrayElementNode.html">StorageArrayElementNode</a></span> </h3>
					<div class="method">
						<div class="description">
							<p>Enables element access with the given index node.</p>
						</div>
						<table class="params">
							<tbody>
								<tr>
									<td class="name">
										<strong>indexNode</strong>
									</td>
									<td class="description last">
										<p>The index node.</p>
									</td>
								</tr>
							</tbody>
						</table>
						<dl class="details">
							<dt class="tag-returns"><strong>Returns:</strong> A node representing the element access.</dt>
						</dl>
					</div>
					<h3 class="name name-method" id="generate" translate="no">.<a href="#generate">generate</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : string</span> </h3>
					<div class="method">
						<div class="description">
							<p>Generates the code snippet of the storage buffer node.</p>
						</div>
						<table class="params">
							<tbody>
								<tr>
									<td class="name">
										<strong>builder</strong>
									</td>
									<td class="description last">
										<p>The current node builder.</p>
									</td>
								</tr>
							</tbody>
						</table>
						<dl class="details">
							<dt class="tag-overrides"><strong>Overrides:</strong> <a href="BufferNode.html#generate">BufferNode#generate</a></dt>
						</dl>
						<dl class="details">
							<dt class="tag-returns"><strong>Returns:</strong> The generated code snippet.</dt>
						</dl>
					</div>
					<h3 class="name name-method" id="getAttributeData" translate="no">.<a href="#getAttributeData">getAttributeData</a><span class="signature">()</span><span class="type-signature"> : Object</span> </h3>
					<div class="method">
						<div class="description">
							<p>Returns attribute data for this storage buffer node.</p>
						</div>
						<dl class="details">
							<dt class="tag-returns"><strong>Returns:</strong> The attribute data.</dt>
						</dl>
					</div>
					<h3 class="name name-method" id="getHash" translate="no">.<a href="#getHash">getHash</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : string</span> </h3>
					<div class="method">
						<div class="description">
							<p>This method is overwritten since the buffer data might be shared
and thus the hash should be shared as well.</p>
						</div>
						<table class="params">
							<tbody>
								<tr>
									<td class="name">
										<strong>builder</strong>
									</td>
									<td class="description last">
										<p>The current node builder.</p>
									</td>
								</tr>
							</tbody>
						</table>
						<dl class="details">
							<dt class="tag-overrides"><strong>Overrides:</strong> <a href="BufferNode.html#getHash">BufferNode#getHash</a></dt>
						</dl>
						<dl class="details">
							<dt class="tag-returns"><strong>Returns:</strong> The hash.</dt>
						</dl>
					</div>
					<h3 class="name name-method" id="getInputType" translate="no">.<a href="#getInputType">getInputType</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : string</span> </h3>
					<div class="method">
						<div class="description">
							<p>Overwrites the default implementation to return a fixed value <code>'indirectStorageBuffer'</code> or <code>'storageBuffer'</code>.</p>
						</div>
						<table class="params">
							<tbody>
								<tr>
									<td class="name">
										<strong>builder</strong>
									</td>
									<td class="description last">
										<p>The current node builder.</p>
									</td>
								</tr>
							</tbody>
						</table>
						<dl class="details">
							<dt class="tag-overrides"><strong>Overrides:</strong> <a href="BufferNode.html#getInputType">BufferNode#getInputType</a></dt>
						</dl>
						<dl class="details">
							<dt class="tag-returns"><strong>Returns:</strong> The input type.</dt>
						</dl>
					</div>
					<h3 class="name name-method" id="getMemberType" translate="no">.<a href="#getMemberType">getMemberType</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span>, name : <span class="param-type">string</span> )</span><span class="type-signature"> : string</span> </h3>
					<div class="method">
						<div class="description">
							<p>Returns the type of a member of the struct.</p>
						</div>
						<table class="params">
							<tbody>
								<tr>
									<td class="name">
										<strong>builder</strong>
									</td>
									<td class="description last">
										<p>The current node builder.</p>
									</td>
								</tr>
								<tr>
									<td class="name">
										<strong>name</strong>
									</td>
									<td class="description last">
										<p>The name of the member.</p>
									</td>
								</tr>
							</tbody>
						</table>
						<dl class="details">
							<dt class="tag-overrides"><strong>Overrides:</strong> <a href="BufferNode.html#getMemberType">BufferNode#getMemberType</a></dt>
						</dl>
						<dl class="details">
							<dt class="tag-returns"><strong>Returns:</strong> The type of the member.</dt>
						</dl>
					</div>
					<h3 class="name name-method" id="getNodeType" translate="no">.<a href="#getNodeType">getNodeType</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : string</span> </h3>
					<div class="method">
						<div class="description">
							<p>This method is overwritten since the node type from the availability of storage buffers
and the attribute data.</p>
						</div>
						<table class="params">
							<tbody>
								<tr>
									<td class="name">
										<strong>builder</strong>
									</td>
									<td class="description last">
										<p>The current node builder.</p>
									</td>
								</tr>
							</tbody>
						</table>
						<dl class="details">
							<dt class="tag-overrides"><strong>Overrides:</strong> <a href="BufferNode.html#getNodeType">BufferNode#getNodeType</a></dt>
						</dl>
						<dl class="details">
							<dt class="tag-returns"><strong>Returns:</strong> The node type.</dt>
						</dl>
					</div>
					<h3 class="name name-method" id="getPBO" translate="no">.<a href="#getPBO">getPBO</a><span class="signature">()</span><span class="type-signature"> : boolean</span> </h3>
					<div class="method">
						<div class="description">
							<p>Returns the <code>isPBO</code> value.</p>
						</div>
						<dl class="details">
							<dt class="tag-returns"><strong>Returns:</strong> Whether the node represents a PBO or not.</dt>
						</dl>
					</div>
					<h3 class="name name-method" id="setAccess" translate="no">.<a href="#setAccess">setAccess</a><span class="signature">( value : <span class="param-type">string</span> )</span><span class="type-signature"> : <a href="StorageBufferNode.html">StorageBufferNode</a></span> </h3>
					<div class="method">
						<div class="description">
							<p>Defines the node access.</p>
						</div>
						<table class="params">
							<tbody>
								<tr>
									<td class="name">
										<strong>value</strong>
									</td>
									<td class="description last">
										<p>The node access.</p>
									</td>
								</tr>
							</tbody>
						</table>
						<dl class="details">
							<dt class="tag-returns"><strong>Returns:</strong> A reference to this node.</dt>
						</dl>
					</div>
					<h3 class="name name-method" id="setAtomic" translate="no">.<a href="#setAtomic">setAtomic</a><span class="signature">( value : <span class="param-type">boolean</span> )</span><span class="type-signature"> : <a href="StorageBufferNode.html">StorageBufferNode</a></span> </h3>
					<div class="method">
						<div class="description">
							<p>Defines whether the node is atomic or not.</p>
						</div>
						<table class="params">
							<tbody>
								<tr>
									<td class="name">
										<strong>value</strong>
									</td>
									<td class="description last">
										<p>The atomic flag.</p>
									</td>
								</tr>
							</tbody>
						</table>
						<dl class="details">
							<dt class="tag-returns"><strong>Returns:</strong> A reference to this node.</dt>
						</dl>
					</div>
					<h3 class="name name-method" id="setPBO" translate="no">.<a href="#setPBO">setPBO</a><span class="signature">( value : <span class="param-type">boolean</span> )</span><span class="type-signature"> : <a href="StorageBufferNode.html">StorageBufferNode</a></span> </h3>
					<div class="method">
						<div class="description">
							<p>Defines whether this node is a PBO or not. Only relevant for WebGL.</p>
						</div>
						<table class="params">
							<tbody>
								<tr>
									<td class="name">
										<strong>value</strong>
									</td>
									<td class="description last">
										<p>The value so set.</p>
									</td>
								</tr>
							</tbody>
						</table>
						<dl class="details">
							<dt class="tag-returns"><strong>Returns:</strong> A reference to this node.</dt>
						</dl>
					</div>
					<h3 class="name name-method" id="toAtomic" translate="no">.<a href="#toAtomic">toAtomic</a><span class="signature">()</span><span class="type-signature"> : <a href="StorageBufferNode.html">StorageBufferNode</a></span> </h3>
					<div class="method">
						<div class="description">
							<p>Convenience method for making this node atomic.</p>
						</div>
						<dl class="details">
							<dt class="tag-returns"><strong>Returns:</strong> A reference to this node.</dt>
						</dl>
					</div>
					<h3 class="name name-method" id="toReadOnly" translate="no">.<a href="#toReadOnly">toReadOnly</a><span class="signature">()</span><span class="type-signature"> : <a href="StorageBufferNode.html">StorageBufferNode</a></span> </h3>
					<div class="method">
						<div class="description">
							<p>Convenience method for configuring a read-only node access.</p>
						</div>
						<dl class="details">
							<dt class="tag-returns"><strong>Returns:</strong> A reference to this node.</dt>
						</dl>
					</div>
				<h2 class="subsection-title">Source</h2>
				<p>
					<a href="https://github.com/mrdoob/three.js/blob/master/src/nodes/accessors/StorageBufferNode.js" translate="no" target="_blank" rel="noopener">src/nodes/accessors/StorageBufferNode.js</a>
				</p>
			</article>
		</section>
<script src="../scripts/linenumber.js"></script>
<script src="../scripts/page.js"></script>
</body>
</html>